Skip to content

Conversation

@ConsoleCatzirl
Copy link
Member

@ConsoleCatzirl ConsoleCatzirl commented Jun 24, 2025

Add a new API endpoint /balances to output a CSV of GL account
balances appropriate for sending to FloQast.

During the first week of the month, process the balance for the previous
month, otherwise process the month-to-date balance.

The pre-existing endpoints used the Program segment of the chart of
accounts, but the new endpoint uses the GL segment of the chart of
accounts. Refactor fetching the chart of accounts to support arbitrary
segments.

Depends on #52

@ConsoleCatzirl ConsoleCatzirl requested a review from Copilot June 24, 2025 00:51

This comment was marked as outdated.

@coveralls
Copy link
Collaborator

coveralls commented Jun 24, 2025

Coverage Status

coverage: 90.215% (-4.9%) from 95.076%
when pulling 8c36847 on ConsoleCatzirl:balances
into 0b660f4 on Sage-Bionetworks-IT:master.

@ConsoleCatzirl ConsoleCatzirl marked this pull request as ready for review June 24, 2025 18:20
@ConsoleCatzirl ConsoleCatzirl requested review from a team as code owners June 24, 2025 18:20
@ConsoleCatzirl ConsoleCatzirl changed the title [IT-4373] Add endpoint to emit current balances as CSV [IT-4485] Add endpoint to emit current balances as CSV Jun 25, 2025
@ConsoleCatzirl ConsoleCatzirl marked this pull request as draft June 27, 2025 16:05
Copy link

@brucehoff brucehoff left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@ConsoleCatzirl ConsoleCatzirl marked this pull request as ready for review June 30, 2025 16:58
Copy link

@brucehoff brucehoff left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very nice updates to documentation.
Please add unit tests for _balance_dates()

| priority_codes | Comma-separated list of numeric codes |
| limit | Integer |

Boolean values: any value other than "no", "off", or "false" will be interpreted
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The description below seems to indicate that the default for these params is true? Why not just make it so that any value other than a case-insensitive true is considered false?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The goal is for them to enable optional behavior, so not providing a param would be considered disabled, and setting any value except for explicit False values would be considered enabled. Also, this way the empty string is True, so just having ?show_other_code is enough to enable the behavior, instead of needing ?show_other_code=true.

@ConsoleCatzirl ConsoleCatzirl marked this pull request as draft July 21, 2025 22:50
@ConsoleCatzirl ConsoleCatzirl force-pushed the balances branch 2 times, most recently from f890b32 to 19933ea Compare July 21, 2025 23:10
@ConsoleCatzirl ConsoleCatzirl marked this pull request as ready for review July 24, 2025 16:54

This comment was marked as outdated.

@ConsoleCatzirl ConsoleCatzirl force-pushed the balances branch 4 times, most recently from 93d6e4e to ac18b92 Compare July 28, 2025 22:59
@dpulls
Copy link

dpulls bot commented Jul 28, 2025

🎉 All dependencies have been resolved !

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR adds a new /balances endpoint that outputs CSV data of GL account balances, designed for FloQast integration. The endpoint dynamically calculates the target period (previous month during the first week, or month-to-date otherwise) and uses the GL segment of the chart of accounts instead of the Program segment used by existing endpoints.

Key changes:

  • Added /balances API endpoint with CSV output format
  • Refactored chart of accounts fetching to support arbitrary segments (Program vs GL)
  • Implemented dynamic period calculation based on current date
  • Added comprehensive test coverage for new functionality

Reviewed Changes

Copilot reviewed 9 out of 12 changed files in this pull request and generated no comments.

Show a summary per file
File Description
tests/unit/test_handler.py Extensive test additions for new balances functionality, period calculations, and updated mocking
template.yaml Added new API route, updated parameter names, and enhanced S3/KMS permissions
mip_api/util.py Added period calculation logic and improved parameter handling functions
mip_api/upstream.py Refactored to support arbitrary chart segments and added trial balance API calls
mip_api/s3.py Extracted caching logic into reusable functions with improved error handling
mip_api/chart.py Split chart retrieval into Program and GL variants, updated function signatures
mip_api/balances.py New module for balance processing and CSV formatting
mip_api/init.py Updated main handler to support new endpoint and refactored parameter handling
README.md Updated documentation to reflect new endpoint and parameter changes
Comments suppressed due to low confidence (1)

Copy link

@brucehoff brucehoff left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for addressing my requests.

Copy link

@zaro0508 zaro0508 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This PR is a big change and difficult to review because the refactor (in PR #52) is included. Please help out reviewers by rebasing onto master and push up a new commit so that the files diffs only show the difference for this specific change.

Prepare for a new API endpoint that will require a different segment
of the chart of accounts.

The pre-existing endpoints used the Program segment of the chart of
accounts, but the new endpoint uses the GL segment of the chart of
accounts.

Refactor to allow arbitrary segments of the chart of accounts.
Add a new API endpoint `/balances` to output a CSV of GL account
balances appropriate for sending to FloQast.

During the first week of the month, process the balance for the previous
month, otherwise process the month-to-date balance.
Copy link

@zaro0508 zaro0508 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, but why does the CI run the coverall check twice?

image

@ConsoleCatzirl
Copy link
Member Author

that's an excellent question, that's kinda weird behavior. the website also sporadically fails to load for me, so I think they're having some sort of extended partial outage. this is one more way that coveralls has been kinda unreliable, and tbh I'm starting to regret not choosing CodeCov for code coverage.

@ConsoleCatzirl ConsoleCatzirl merged commit 6f7aee4 into Sage-Bionetworks-IT:master Aug 19, 2025
5 checks passed
@ConsoleCatzirl ConsoleCatzirl deleted the balances branch August 19, 2025 16:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants